#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

#include "spi.h"

static unsigned char tx[256];
static unsigned char rx[256];

void display(unsigned char *buf, int start, int end)
{
	int i;

	for(i = start; i < end; i++) {
                printf("%2x ", buf[i]);

                if( i % 16 == 15)
                        printf("\n");
        }
}

void address_pattern()
{
	int i;

	for (i = 0; i < 256; i+=2) {
		tx[i] = 0x55;
		tx[i+1] = 0xaa;
	}

	spi_rw(4, tx, rx, 256);

}

void random_pattern()
{
	int i;

	for (i = 0; i < 256; i++)
		tx[i] = i;

	spi_rw(4, tx, rx, 256);
}


int main(int argc, char *argv[])
{
	spi_open(4, 10000000);

	printf("spi init ok!\n");

 	random_pattern();   
	display(rx, 0, 256);


	return 0;
}
